package com.lmiot.xyclick.Activity;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.lmiot.xyclick.App.MyApp;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.ImgUtil;
import com.lmiot.xyclick.Util.StateBarUtil;
import com.lmiot.xyclick.Util.TimeUtils;
import com.xiaoyi.intentsdklibrary.SDK.Action.ActionNormalSDK;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import com.youyi.yyviewsdklibrary.View.TitleBarView;
import java.io.File;

public class WxGonActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "WxGonActivity";
    ImageView mIdImg;
    TextView mIdStart;
    TitleBarView mIdTitleBar;

    /* access modifiers changed from: protected */
    @Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.SupportActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_wx_gon);
        initView();
        StateBarUtil.immersive(this);
        StateBarUtil.setPadding(this, this.mIdTitleBar);
        try {
            Glide.with((FragmentActivity) this).load("https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/gon.jpg").apply(new RequestOptions().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).fitCenter()).into(this.mIdImg);
        } catch (Exception e) {
            e.printStackTrace();
            Glide.with((FragmentActivity) this).load(Integer.valueOf((int) R.drawable.gon)).into(this.mIdImg);
        }
        this.mIdTitleBar.setOnItemClickListener(new TitleBarView.onItemClickListener() {
            /* class com.lmiot.xyclick.Activity.WxGonActivity.AnonymousClass1 */

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onMenuClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onTitleClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onBackClick(View view) {
                WxGonActivity.this.finish();
            }
        });
    }

    private static void startWechat(Context context) {
        try {
            ActionNormalSDK.getInstance().toolWxZxing(context);
        } catch (Exception e) {
            e.printStackTrace();
            ToastUtil.err("请先安装微信！");
        }
    }

    private void initView() {
        this.mIdTitleBar = (TitleBarView) findViewById(R.id.id_title_bar);
        this.mIdImg = (ImageView) findViewById(R.id.id_img);
        TextView textView = (TextView) findViewById(R.id.id_start);
        this.mIdStart = textView;
        textView.setOnClickListener(this);
    }

    public void onClick(View view) {
        if (view.getId() == R.id.id_start) {
            Bitmap viewToBitmap = ImgUtil.viewToBitmap(this.mIdImg);
            try {
                File filesDir = MyApp.getContext().getFilesDir();
                File file = new File(filesDir, TimeUtils.getCurrentTime() + "wxauto.jpg");
                if (!file.exists()) {
                    new File(file.getParent()).mkdirs();
                    file.createNewFile();
                }
                ImgUtil.noticSystem(ImgUtil.saveBitmpToFile(viewToBitmap, file));
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Throwable th) {
                startWechat(this);
                throw th;
            }
            startWechat(this);
        }
    }
}
